<template>
	<uni-popup type="bottom" ref="rewardRecord">
		<view class="rewardRecord">
			<div class="header">
				<img @click="close" src="../static/close.svg" class="close-icon" alt="" srcset="">
				<text class="header-title">金币明细</text>
			</div>
			<div class="body">

				<div class="coins-item" v-for="item in recordList" :key="item.id">
					<div>
						<div class="event">{{item.remark}}</div>
						<div class="date">{{parseTime(item.createTime,"{y}-{m}-{d}")}}</div>
					</div>
					<div :class="{'add':item.type===1,'reduce':item.type === 2}">{{item.type ===1?"+":'-'}}1</div>
				</div>
				<uni-load-more :status="status" :content-text="contentText" @clickLoadMore="getData()"></uni-load-more>

			</div>
		</view>
	</uni-popup>
</template>

<script>
	import {
		getWalletPage
	} from '../api/wallet'
	export default {
		name: "RewardRecordPopup",
		data() {
			return {
				pageParam: {
					pageNo: 1,
					pageSize: 10
				},
				contentText: {
					contentdown: '点击加载更多',
					contentrefresh: '加载中',
					contentnomore: '暂无更多~'
				},
				status: 'more',
				recordList: []
			};
		},
		created() {

		},
		methods: {
			open() {
				this.$refs.rewardRecord.open()
				this.status = 'more'
				this.getData()
			},
			close() {
				this.$refs.rewardRecord.close()
			},
			getData() {
				if (this.status !== 'noMore') {
					getWalletPage(Object.assign(this.pageParam)).then(result => {
						console.log("getWalletPage", result)
						//1 add 2 reduce
						this.recordList = this.recordList.concat(result.data.list)
						if (result.data.list >= this.pageParam.pageSize) {
							this.pageParam.pageNo++;
						} else {
							this.status = 'noMore'
						}


					})
				}

			},
		}
	}
</script>

<style lang="scss" scoped>
	.rewardRecord::after {
		display: table;
		content: "";
		clear: both;
	}

	.rewardRecord {
		background-color: white;
		border-top-left-radius: 30upx;
		border-top-right-radius: 30upx;
		padding-top: 24upx;

		.header {
			height: 80upx;
			display: flex;
			align-items: center;
			justify-content: center;
			position: relative;


			.header-title {
				font-size: 30upx;
				font-weight: bolder;
			}

			.close-icon {
				width: 40upx;
				height: 40upx;
				position: absolute;
				left: 24upx;
				top: 20upx;
			}

		}

		.body {
			max-height: 600upx;
			overflow: auto;
			padding: 32upx 16upx;
			margin-bottom: 24upx;

			.coins-item {
				align-items: center;
				border-radius: 16upx;
				box-shadow: 0 4upx 16upx 0 rgba(0, 0, 0, .1);
				display: flex;
				justify-content: space-between;
				margin-bottom: 16upx;
				padding: 16upx 32upx;

				.event {
					font-size: 28upx;
					font-weight: 600
				}

				.date {
					color: #848484;
					font-size: 24upx
				}

				.add {
					color: $uni-color-primary;
					font-size: 42upx;
					font-weight: 600
				}

				.reduce {

					color: #e50808;
					font-size: 42upx;
					font-weight: 600
				}



			}

		}
	}
</style>